<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>登录</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <style>
        .fakeimg {
            height: 200px;
            background: #aaa;
        }
    </style>
</head>
<body>
<div class="jumbotron text-center" style="margin-bottom:0">
    <h1>来聊天啊!</h1>
    <p>啦啦啦</p>
</div>

<div class="container">
    <div class="row">
        <div class="col-sm-4" style=" margin: 5%;">
            <form class="form-horizontal" role="form" id="myForm">
                {{csrf_field()}}
                <div class="form-group">
                    <div class="col-sm-10">
                        <input type="text" name="username" class="form-control" id="firstname" placeholder="账号">
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-10">
                        <input type="password" name="pwd" class="form-control" id="lastname" placeholder="密码">
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="submit" class="btn btn-default" id="submit">登录</button>
                    </div>
                </div>
            </form>
            <hr class="hidden-sm hidden-md hidden-lg">
        </div>
    </div>
</div>
<script>
    $('#submit').click(function () {
        var data = $("#myForm").serialize();
        $.ajax({
            type: "post",
            url: "/chat/login",
            data: data,//获得表单数据
            success: function (data) {
                if (data.status === 200) {
                   window.location.href='/chat/index?username='+data.data.username+'&user_id='+data.data.user_id;
                } else {
                    alert(data.msg);
                }
            }
        });
        return false;
    })
</script>
</body>
</html>


